package red.don.meal;

import java.util.Calendar;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Food {

  @Autowired
  private Service service;

  @GetMapping("/menu")
  public String getMenu() {
    int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    if (hour >= 21 || hour <= 5) {
      return "现在是休息时间";
    } else if (hour >= 6 && hour <= 9) {
      return "现在是早餐时间\t餐点：" + this.service.getBreakfast() + "\t厨师：" + this.service.getBreakfastChef();
    } else if (hour >= 10 && hour <= 14) {
      return "现在是午餐时间\t餐点：" + this.service.getLunch() + "\t厨师：" + this.service.getLunchChef();
    } else if (hour >= 15 && hour <= 20) {
      return "现在是晚餐时间\t餐点：" + this.service.getDinner() + "\t厨师：" + this.service.getDinnerChef();
    } else {
      return "出现了一些小意外";
    }
  }

  @GetMapping("/")
  public String getAll() {
    return this.service.toString();
  }

}
